package com.test;

import java.text.SimpleDateFormat;
import java.util.Date;

public class FormatAction extends SelfAction {

	String format ;
	public FormatAction(String format){
		this.format = format;
	}
	@Override
	public boolean doIt(JsonWriter w, JsonKey key, Item value) {
		
		Object o  = value.obj;
		if( o instanceof  Date){
			SimpleDateFormat sdf = new SimpleDateFormat(format);
			String  ret = sdf.format((Date)o);
			w.writeKeyValue(key, new JsonWriter.DirectValue(ret));
		}else{
			throw new UnsupportedOperationException();
		}
		return false;
	}

}
